package com.puzzle;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import common.AudioClip;


public class Main extends Activity implements OnClickListener {
	/** Called when the activity is first created. */
	Button newgame;
	Button about;
	
	AudioClip music;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		newgame = (Button) findViewById(R.id.new_game);
		about = (Button) findViewById(R.id.about);
		
		newgame.setOnClickListener(this);
		about.setOnClickListener(this);
		
		music = new AudioClip(getApplicationContext(), R.raw.main_music);
		music.loop();
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == newgame) {
			music.stop();
			Intent intent = new Intent(Main.this, SelectPicture.class);
			startActivity(intent);
		}
		if(v == about){
			music.stop();
			Intent intent = new Intent(Main.this, About.class);
			startActivity(intent);
		}
	}
	
    @Override
    protected void onResume() {
    	// TODO Auto-generated method stub
    	super.onResume();
    	music.loop();
    }
    
    @Override
    protected void onPause() {
    	// TODO Auto-generated method stub
    	super.onPause();
    	music.stop();
    }
    
    @Override
    protected void onDestroy() {
    	// TODO Auto-generated method stub
    	super.onDestroy();
    	music.release();
    }
	

}